<?php


namespace App\Model;


class CouponRule extends Base
{

    protected $table='coupon_rule';

    protected $fillable=['get_expired_time','limit','expiration_date_type','start_time','end_time','until_days','expiration_days','goods_type'];

    function coupon(){

        return $this->hasMany(Coupon::class,'coupon_rule_id','id');
    }

    function coupon_list(){

        return $this->hasMany(Coupon::class,'coupon_rule_id','id');
    }

    function goods_list(){

        return $this->hasManyThrough(
            GoodsSku::class,
            CouponGoodsSku::class,
            'coupon_rule_id',
            'id',
            'id',
            'goods_sku_id'
        );
    }

    function category_list(){

        return $this->hasManyThrough(
            Category::class,
            CouponGoodsCategory::class,
            'coupon_rule_id',
            'id',
            'id',
            'category_id'
        );

    }

}
